#include <iostream>
#include <windows.h>
#include "MyServer.h"
#include "MyTools.h"

using namespace std;

class ChatServer:public MyServer
{
private:
    void OnReadyToListen(bool ready)
    {
        if(ready)
        {
            MYLOG("Server ready..");
        }
        else
        {
            MYLOG("Server failed..");
        }

    }

    void OnClientConnect(MyConnectedClient *client)
    {
        MYLOG("Client connected..");
    }

    void OnClientDisconnect(MyConnectedClient *client)
    {
        MYLOG("Client disconnected..");
    }

    void OnReceiveMessage(MyConnectedClient *client, MyMsgIn &msg)
    {
        MYLOG("Receive message..");
    }

};

int main()
{
    MYLOG("** Chat Server **");

    ChatServer *server1 = new ChatServer();
    ChatServer *server2 = new ChatServer();
    server1->ListenTo(9999);
    server2->ListenTo(9998);
    for(int i=0; i<20; i++)
    //while(server->IsListening())
    {
        MYLOG("Tick..");
        Sleep(500);
    }
    server1->StopListen();
    server2->StopListen();

    delete server1;
    delete server2;

    return 0;
}
